package com.lee.boot.head.first.demo.schedule;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author: Lee
 * @Date: 2019/1/30 12:08
 * @Description:
 */
@Component
public class ScheduleDemo {
    public final static long ONE_Minute = 60 * 1000;

    @Scheduled(fixedDelay = ONE_Minute)
    public void fixedDelayJob() {
        System.out.println(new Date() + " >>fixedDelay执行....");
    }

    @Scheduled(fixedRate = ONE_Minute)
    public void fixedRateJob() {
        System.out.println(new Date() + " >>fixedRate执行....");
    }

    @Scheduled(cron = "0/6 * * * * ? ")
    public void cronJob() {
        System.out.println(new Date() + " >>cron执行....");
    }
}
